﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using Akiha.Core;
using ESRI.ArcGIS.Geometry;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.esriSystem;
using DevExpress.XtraGrid;
using DevExpress.XtraTreeList;
using DevExpress.XtraGrid.Views.Grid;

   



namespace GIS.GeoDataManage.Dialogs
{
    public partial class XUcGridAndTreeListGroupForAO : DevExpress.XtraEditors.XtraUserControl
    {

        private IMap m_pMap = null;

        public XUcGridAndTreeListGroupForAO()
        {
            InitializeComponent();
        }

        public XUcGridAndTreeListGroupForAO(IMap pMap)
        {
            m_pMap = pMap;
            InitializeComponent();
        }

        //添加默认的事件





        //返回TreeList以及GridControl以供扩展


        public GridControl GridControl { get { return gridControlExtensionForAO1 ; } }

        public GridView GridView { get { return gridView2 ; } }

        public TreeList TreeList { get { return treeListExtensionForAO1; } }




       

        void treeList_FocusedNodeChanged(object sender, FocusedNodeChangedEventArgs e)
        {
            //默认显示当前图层的字段信息
            IFeatureLayer pFeaLyr = e.Node.GetValue(0) as IFeatureLayer;
            if (pFeaLyr != null)
            {
                gridControlExtensionForAO1.ShowTableEx((ITable)(pFeaLyr.FeatureClass), false);
            }
        }

        private void XUcGridAndTreeListGroupForAO_Load(object sender, EventArgs e)
        {
            //重新载入图层到treelist中
            treeListExtensionForAO1.Map = m_pMap;
            treeListExtensionForAO1.FocusedNodeChanged += new FocusedNodeChangedEventHandler(treeList_FocusedNodeChanged);
            treeListExtensionForAO1.LoadLayers();          
            treeListExtensionForAO1.BestFitColumns();
              
            //treeList.GetType().get


            ////动态根据条件设置treeList的样式，将不通过的图层标示为红色
            //treeList.NodeCellStyle += new GetCustomNodeCellStyleEventHandler(treeList_NodeCellStyle);
        }







    }
}
